<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	</head>
	<body class="portalBody Mrphs-portalBody Mrphs-sakai-datemanager-tool">
		<link media="all" href="/library/skin/tool_base.css" rel="stylesheet" type="text/css" />
		<script src="/library/js/headscripts.js" type="text/javascript"></script>
		<script type="text/javascript" src="/library/js/lang-datepicker/lang-datepicker.js"></script>
		<script th:src="@{/js/initDatePicker.js}"></script>
		<script th:inline="javascript">
		  /*<![CDATA[*/
			var sakai = sakai || {}; sakai.editor = sakai.editor || {};
			sakai.locale = sakai.locale || {};
			sakai.locale.userCountry = [[${userCountry}]];
			sakai.locale.userLanguage = [[${userLanguage}]];
			sakai.locale.userLocale = [[${userLocale}]];
			includeLatestJQuery('datemanager/index.html');
		  /*]]>*/
		</script>
		<meta http-equiv="Content-Style-Type" content="text/css" />
		<div class="page-header">
			<h1 th:text="#{page.confirm.import}">Confirmation: Import dates</h1>
		</div>
		<div class="sak-banner-error" th:if="${errors != null}">
			<table>
				<thead>
					<tr>
						<td colspan="2"><p th:text="#{errors.instruction}" class="mb-2">You cannot do those changes because: </p></td>
					</tr>
				</thead>
				<tbody th:each="error : ${errors}">
					<tr class="h5">
						<th><p th:text="${error.get(0).getErrors().get(0).toolTitle}" class="mt-2">Tool title</p></th>
					</tr>
					<tr>
						<td>
							<p th:text="#{template.error(${error.get(1)}, ${error.get(2)})}">You cannot do those changes because: </p>
							<ul>
								<li th:each="errorValidation : ${error.get(0).getErrors()}" th:text="#{template.error(${errorValidation.msg}, ${errorValidation.field})}">You cannot do that changes beacuse: </li>
							</ul>
						</td>
					</tr>
				</tbody>
				<tr>
					<td colspan="2"><p th:text="#{errors.instruction_2}" class="mt-2">Fix the errors</p></td>
				</tr>
			</table>
		</div>
		<div class="sak-banner-warn" th:if="${errors == null}">
			<table>
				<tr>
					<td th:text="#{page.confirm.import.instruction_0}">Are you sure to do those changes</td>
				</tr>
				<tr>
					<td th:text="#{page.confirm.import.instruction_1}">To confirm click on the 'Save' button</td>
				</tr>
			</table>
		</div>
		<form th:action="@{/import/dates/confirm}" method="post">
			<div th:each="toolsAux : ${tools}">
				<div><h1 th:text="${toolsAux.get(0)}">Some tool title</h1></div>
				<table class="table table-condensed table-striped table-bordered table-datemanager">
					<tr>
						<th th:each="columnHeader, iter : ${toolsAux.get(1)[0]}" th:if="${columnHeader != ''}" th:text="${columnHeader}"></th>
					</tr>
					<tr th:each="contents : ${toolsAux.get(2)}">
						<td th:each="content, iter : ${contents}" th:if="${toolsAux.get(1)[0][iter.index] != ''}" th:text="${content.replaceAll('[^a-zA-Z]', '').equals('T') ? #strings.replace(content, 'T', ' ') : content}"></td>
					</tr>
				</table>
			</div>
			<div class="act">
				<input type="submit" class="active" th:value="#{button.save}" id="submit-form-button" th:if="${errors == null}">
				<a th:href="@{/}" id="datemanager-cancel" class="btn btn-secondary datemanager-nav" role="button" th:text="#{button.cancel}" th:if="${errors == null}">Cancel</a>
				<a th:href="@{/}" id="datemanager-start-again" class="btn btn-primary datemanager-nav" role="button" th:text="#{button.start.again}" th:if="${errors != null}">Start again</a>
			</div>
		</form>
		<script th:inline="javascript">
			$(document).on('click', '.datemanager-nav', function(e) {
				e.preventDefault();
				window.location = window.location.href.replace('/import/dates', '/').replace('/confirm', '');
			});
		</script>
	</body>
</html>
